package com.lin.blog.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lin.blog.mapper.ArticleStatisticalMapper;
import com.lin.blog.service.IArticleStatisticalService;
import com.lin.blog.vo.ArticleStatistical;
import com.lin.constant.ResultCode;
import com.lin.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lin
 * @since 2020-03-08
 */
@Service
public class ArticleStatisticalServiceImpl implements IArticleStatisticalService {

    @Autowired
    private ArticleStatisticalMapper articleStatisticalMapper;


    /**
     * 获取文章统计
     * @return
     */
    public Result getArticleStatistical(){
        return Result.success(articleStatisticalMapper.getArticleStatistical());
    }

    /**
     * 获取文章统计 通过username
     * @return
     */
    @Override
    public Result getArticleStatisticalByUsername(String username) {
        // 参数不为空
        if (StringUtils.isEmpty(username)) {
            return Result.failure(ResultCode.PARAM_IS_BLANK);
        }

        return Result.success(articleStatisticalMapper.getArticleStatisticalByUsername(username));
    }





}
